﻿using System;
using Ue.Framework.Data;
using Ue.Infrastructure.EntityFactoryFramework;

namespace Ue.Qcdz.Repositories.Articles
{
    internal class ArticleFactory : IEntityFactory<Domain.Articles.Article>
    {
        internal class FieldNames : FieldNamesBase
        {
            public const string Title = "Title";
            public const string Content = "Content";
            public const string Keyword = "Keyword";
            public const string Editor = "Editor";
            public const string Reference = "Reference";
            public const string IsTop = "IsTop";
            public const string Status = "Status";
            public const string ImageUrl = "ImageUrl";
            public const string Ver = "Ver";
            public const string Remark = "Remark";
            public const string Summary = "Summary";
            public const string SubTitle = "SubTitle";
            public const string TagId = "TagId";
            public const string ClickCount = "ClickCount";
            public const string DisplayOrder = "DisplayOrder";
            public const string TitleColor = "TitleColor";
            public const string IsStrong = "IsStrong";
            public const string Relevance = "Relevance";
            public const string IsFocus = "IsFocus";

        }

        #region IEntityFactory<Article> 成员

        public Domain.Articles.Article BuildEntity(System.Data.IDataReader reader)
        {

            return new ArticleProxy(
                reader.Get<Guid>(ArticleFactory.FieldNames.EntityKey),
                reader.Get<string>(ArticleFactory.FieldNames.Title),
                reader.Get<string>(ArticleFactory.FieldNames.SubTitle),
                reader.Get<string>(ArticleFactory.FieldNames.Summary),
                reader.Get<string>(ArticleFactory.FieldNames.Reference),
                reader.Get<string>(ArticleFactory.FieldNames.Keyword),
                reader.Get<string>(ArticleFactory.FieldNames.Editor),
                reader.Get<string>(ArticleFactory.FieldNames.ImageUrl),
                reader.Get<string>(ArticleFactory.FieldNames.Content),
                reader.Get<int>(ArticleFactory.FieldNames.DisplayOrder),
                reader.Get<int>(ArticleFactory.FieldNames.IsTop),
                reader.Get<int>(ArticleFactory.FieldNames.Status),
                reader.Get<string>(ArticleFactory.FieldNames.TitleColor),
                reader.Get<int>(ArticleFactory.FieldNames.IsStrong),
                reader.Get<DateTime>(ArticleFactory.FieldNames.CreateOn),
                reader.Get<string>(ArticleFactory.FieldNames.Relevance),
                reader.Get<int>(ArticleFactory.FieldNames.ClickCount),
                reader.Get<int>(ArticleFactory.FieldNames.IsFocus)
                );
        }

        #endregion
    }
}
